﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using Jzy.Workflow.Node;
using Frame.Lib.Data;
using Frame.Lib.Core.Base;

namespace Jzy.Workflow.Line
{
    public class FlowLineBO : CommonOperate<FlowLineInfo>
    {
        private FlowLineDAL _flowLine;

        protected override BaseDAL DAL
        {
            get
            {
                return _flowLine;
            }
        }

        public FlowLineBO()
            : base("FlowLine")
        {
            _flowLine = new FlowLineDAL();
        }

        public FlowLineBO(DBHelper db):this()
        {
            base.dbOper = _flowLine.dbOper = db;
        }

        public override FlowLineInfo GetInfo(object id)
        {
            FlowLineInfo info = base.GetInfo(id);
            info.GetNodeInfo = nodeID => (new FlowNodeBO()).GetInfo(nodeID);
            return info;
        }

        public List<FlowLineInfo> GetList(int flowID)
        {
            List<FlowLineInfo> list = _flowLine.GetList(flowID);
            return list;
        }

        internal void DeleteByNodeID(object nodeID)
        {
            _flowLine.DeleteByNodeID(nodeID);
        }

      
        public bool Exist(int fromNodeID, int toNodeID, object id)
        {
            return _flowLine.Exist(fromNodeID, toNodeID, id);
        }
    }
}
